package com.cskaoyan.service.admin.impl;

import com.cskaoyan.bean.BasePageInfo;
import com.cskaoyan.bean.MarketFeedback;
import com.cskaoyan.bean.MarketFeedbackExample;
import com.cskaoyan.bean.param.CommonData;
import com.cskaoyan.mapper.MarketFeedbackMapper;
import com.cskaoyan.service.admin.MarketFeedbackService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author LC_RSH
 * @date 2022/6/26 15:04
 */
@Service
public class MarketFeedbackServiceImpl implements MarketFeedbackService {
    @Autowired
    MarketFeedbackMapper feedbackMapper;

    /**
     * 通过username和userId展示意见反馈
     *
     * @return
     * @author LC_R-SH
     * @since 2022/06/26 16:22
     */
    @Override
    public CommonData<MarketFeedback> query(String username, Integer id, BasePageInfo info) {
        PageHelper.startPage(info.getPage(), info.getLimit());
        MarketFeedbackExample marketFeedbackExample = new MarketFeedbackExample();
        MarketFeedbackExample.Criteria criteria = marketFeedbackExample.createCriteria();
        if (!StringUtils.isEmpty(username)) {
            username = "%" + username.trim() + "%";
            criteria.andUsernameLike(username);
        }
        if (id != 0) {
            criteria.andIdEqualTo(id);
        }
        criteria.andDeletedEqualTo(false);
        marketFeedbackExample.setOrderByClause("update_time desc");
        List<MarketFeedback> feedbackList = feedbackMapper.selectByExample(marketFeedbackExample);
        PageInfo<MarketFeedback> data = new PageInfo(feedbackList);
        return CommonData.data(data);
    }
}

/**
 * 意见反馈
 *
 * @author 86157
 * @since 2022/06/26 15:04
 */